# -*- coding: utf-8 -*- 

class Product(object):
    def __init__(self):
        self._insertupdate=None
        self._keyfield=None
        
    def getInsertSQL(self):#生成插入到数据库的SQL
        tablename=self.__class__.__name__
        idict=self.__dict__
        if self._insertupdate=='insert':
            sql_1='insert ignore into '+tablename+'('
            sql_2=') values('
            for i,j in idict.items():
                if i[0]!='_':
                    if j!=None:
                        sql_1+=i+','
                        sql_2+="'"+j+"',"
            sql=sql_1[:-1]+sql_2[:-1]+')'
            return sql
        elif self._insertupdate=='update':
            sql_1='update '+tablename+' set '
            sql_2=' where '+self._keyfield+'="'+self.__dict__[self._keyfield]+'"'
            for i,j in idict.items():
                if i[0]!='_':
                    if j!=None:
                        sql_1+=i+'='+"'"+j+"',"
            sql=sql_1[:-1]+sql_2
            return sql
        
class Commodity(Product):
    def __init__(self):
        Product.__init__(self)
        self.id=None
        self.fromwhere=None
        self.shop=None
        self.name=None
        self.href=None
        self.cate=None
        self.brand=None
            
class Customer(Product):
    def __init__(self):
        self._keyfield='userid'
        self.usercode=None
        self.userid=None
        self.fullname=None#全名
        self.sex=None
        self.born_month=None
        self.born_day=None
        self.postcode=None
        self.fans_count=None
        self.follows_count=None
        self.email=None
        self.qq=None
        self.buycredit=None
        self.salecredit=None
        self.usetag=None
        
        
class CustomerBuyRecord(Product):#仅用来参考
    def __init__(self):
        self.fullname=None#全名
        self.guessname=None#简化名字
        self.vip=None#会员等级
        self.credit=None#信用等级
        self.buycomidity_id=None
        self.buycomidity_fullname=None
        self.buycomidity_shop=None
        self.buycomidity_sku=None
        self.buycomidity_cate=None
        self.buycomidity_brand=None
        self.buytime=None
        self.buyprice=None
        
class CustomerJudgeRecord(Product):#筛选出部分有用的用户名
    def __init__(self):
        self.fullname=None#全名
        self.guessname=None#简化名字
        self.vip=None#会员等级
        self.credit=None#信用等级
        self.buycomidity_id=None
        self.buycomidity_fullname=None
        self.buycomidity_shop=None
        self.buycomidity_sku=None
        self.buycomidity_cate=None
        self.buycomidity_brand=None
        self.buytime=None
        self.buyprice=None
        
class Customer_QQ_WeiBo(Product):
    def __init__(self):
        self._keyfield='usercode'
        self.usercode=None
        self.fullname=None#nickname
        self.link=None
        self.sex=None
        self.Constellation=None#星座
        self.address=None
        self.fans_count=None
        self.follows_count=None
        self.email=None
        self.qq=None
        self.usetag=None
